<style>
    .member-box *{
        list-style: none;
        margin:0;
        padding:0;
        font-size:12px;
        line-height: 24px;
    }
    .pink{color:pink;}
    .am-btn-group .am-btn-secondary.btn-pink {
        color: #fff;
        background-color: pink;
        border-color: pink;
    }
    .am-btn-group .am-btn-secondary.btn-pink:focus, .am-btn-group .am-btn-secondary.btn-pink:hover {
        background-color: pink;
    }
    .am-btn-group .am-btn-secondary.btn-green {
        color: #fff;
        background-color: #5eb95e;
        border-color: #5eb95e;
    }
    .am-btn-group .am-btn-secondary.btn-green:focus, .am-btn-group .am-btn-secondary.btn-green:hover {
        background-color: #5eb95e;
    }
    .am-btn-group .am-btn-secondary.btn-blue {
        color: #fff;
        background-color: #3bb4f2;
        border-color: #3bb4f2;
    }
    .am-btn-group .am-btn-secondary.btn-blue:focus, .am-btn-group .am-btn-secondary.btn-blue:hover {
        background-color: #3bb4f2;
    }
    .member-box .operation-select .am-dropdown-toggle.am-btn-sm{padding:0 1em}
    .member-box{padding-top:20px;}
    .member-box > ul{
        display:flex;
        flex-wrap: wrap;
    }
    .member-box > ul > li{
        position:relative;
        width:290px;
        height:398px;
        margin:0 10px 10px 0;
        border:1px solid #eee;
        border-radius: 8px;
        background-color: #f5f5f5;
    }
    .person-info{
        border-top-left-radius: 8px;
        border-top-right-radius: 8px;
        display: flex;
        flex-wrap: nowrap;
        padding:15px 15px 0 15px;
        background-color: #3bb4f2;
    }
    .person-info > dt
    {
        position: relative;
        flex:0 70px;
        height:90px;
        border-radius: 50%;
    }
    .person-info > dt img{
        width:60px;
        height:60px;
        overflow: hidden;
        border-radius: 50%;
    }
    .person-info > dt label{
        position: absolute;
        display: block;
        width:60px;
        height:20px;
        line-height: 20px;
        font-weight: normal;
        font-size:10px;
        text-align: center;
        border-radius:15px;
        background-color:rgba(0,0,0,.8);
        color:#fff;
        top:40px;
    }
    .person-info > dt p{
        display: block;
        width:100%;
        color:#fff;
        font-size:12px;
        font-weight: normal;
    }
    .person-info > dd{
        padding-left:10px;
        flex:0 calc(100% - 80px);
        color:#fff;
    }
    .person-info > dd span{
        position: relative;
        width:100%;
        display: block;
    }
    .person-info > dd span .blue{
        position:absolute;
        margin-left:10px;
        color:#3CB7FD;
        height:20px;
        line-height:20px;
        width:20px;
        border-radius: 50%;
        text-align: center;
        font-weight: bold;
        background-color: #fff;
        top:2px;
        right:0;
    }
    .person-info > dd span .pink{
        position:absolute;
        margin-left:10px;
        color:pink;
        height:20px;
        line-height:20px;
        width:20px;
        border-radius: 50%;
        text-align: center;
        font-weight: bold;
        background-color: #fff;
        top:2px;
        right:0;
    }
    .person-info > dd span.person-contact,.person-address{
        display: flex;
        text-align: left;
    }
    .person-info > dd span.person-contact i,.person-address i{
        display:block;
        width:20px;
        font-size: 18px;
    }
    .person-info > dd span.person-contact em{
        display: block;
        font-style: normal;
    }
    .person-address{
        position:relative;
        padding:0 15px 8px 15px;
        background:#3bb4f2;
        color:#fff;
    }
    .person-address i
    {
        position: absolute;
        left:15px;
        top:0;
        font-size:24px;
    }
    .person-address span{
        display: block;
        line-height:20px;
        height:40px;
        overflow:hidden;
        padding-left:25px;
        font-size:12px;
    }
    .person-wallet{
        display: flex;
        width:100%;
        padding:3px 0;
        border-top:1px solid #eee;
        border-bottom:1px solid #eee;
        background:#fff;
    }
    .person-wallet span{
        display: block;
        width:calc((100% - 1px) / 3);
        text-align: center;
        border-right:1px solid #eee;
    }
    .person-wallet span:last-child{
        border-right:0;
    }
    .person-wallet span label{
        line-height:18px;
        color:#999;
        font-weight: normal;
    }
    .person-wallet span p{
        line-height:20px;
        font-weight: bold;
        color:#a60000;
    }
    .person-introduce{
        position: relative;
        padding:10px 15px 6px 15px;
        border-bottom:1px solid #eee;
        overflow: hidden;
        background:#fff;
    }
    .person-tag{
        display: flex;
        flex-wrap: wrap;
        max-height: 48px;
        overflow: hidden;
    }

    .person-tag span,.person-tag .edittags{
        display: block;
        padding:0 8px;
        font-size:12px;
        border-radius:8px;
        margin-right:5px;
        background-color:#ecf8ff;
    }

    .person-tag .edittags{
        background-color:#d9d9d9;
        color:#333;
        margin-right: 8px;
    }
    .person-notes{
        height:40px;
        line-height:20px;
        margin-top:8px;
        overflow: hidden;
        text-overflow: ellipsis;
        display:-webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        font-size:12px;
    }
    .person-source{
        padding:10px;
    }
    .person-source dl{
        display: flex;
        width: 100%;
        font-size:12px;
    }
    .person-source dl dt{
        font-weight: normal;
        font-size:12px;
    }
    .person-source dl dd{
        display: block;
        width:60%;
        text-align: right;
        margin-left:auto;
    }
    .person-source dl dd button{
        padding:0 5px;
        height:24px;
        border-radius:2px;
        font-size: 12px;
        float:none !important;
    }
    .person-source dl:first-child dt span{
        color:#3bb4f2;
    }
    .person-source dl dt span{
        color:#a60000
    }
    .member-btns{
        height:28px;
        margin:5px 0 0 0;
    }
    .member-btns button{
        padding:0 5px;
        font-size:12px;
        border-radius:5px
    }
    .member-btns.am-btn-toolbar .am-btn-group > .am-btn{
        margin-right:0;
    }
    .operation-select .am-dropdown-toggle.am-btn-sm{
        padding:0 5px !important
    }
    .member-btns .am-btn-group .am-dropdown-content{
        min-width:auto;
    }
</style>

<div class="row-content am-cf">
    <div class="row">
        <div class="" style="width:100%;">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-cf">用户列表</div>
                </div>
                <div class="widget-body am-fr">
                    <!--
							<div class="page_toolbar am-margin-bottom-xs am-cf">
								<div class="am-form-group">
									<div class="am-btn-toolbar">
										<div class="am-btn-group am-btn-group-xs">
											<a class="am-btn am-btn-default am-btn-success am-radius"
											   href="<?= url('user/add') ?>">
												<span class="am-icon-plus"></span> 新增线下无微信用户
											</a>
										</div>
									</div>
								</div>
							</div>
						-->
                    <!-- 工具栏 -->
                    <div class="page_toolbar am-margin-bottom-xs am-cf">
                        <form class="toolbar-form" action="">
                            <input type="hidden" name="s" value="/<?= $request->pathinfo() ?>">
                            <div class="">
                                <div class="am fr">
                                    <div class="am-form-group am-fl">
                                        <?php $grade = $request->get('grade'); ?>
                                        <select name="grade"
                                                data-am-selected="{btnSize: 'sm', placeholder: '请选择会员等级'}">
                                            <option value=""></option>
                                            <?php foreach ($gradeList as $item): ?>
                                                <option value="<?= $item['grade_id'] ?>"
                                                    <?= $grade == $item['grade_id'] ? 'selected' : '' ?>><?= $item['name'] ?>
                                                </option>
                                            <?php endforeach; ?>
                                        </select>
                                    </div>
                                    <div class="am-form-group am-fl">
                                        <?php $gender = $request->get('gender'); ?>
                                        <select name="gender"
                                                data-am-selected="{btnSize: 'sm', placeholder: '请选择性别'}">
                                            <option value=""></option>
                                            <option value="-1"
                                                <?= $gender === '-1' ? 'selected' : '' ?>>全部
                                            </option>
                                            <option value="1"
                                                <?= $gender === '1' ? 'selected' : '' ?>>男
                                            </option>
                                            <option value="2"
                                                <?= $gender === '2' ? 'selected' : '' ?>>女
                                            </option>
                                            <option value="0"
                                                <?= $gender === '0' ? 'selected' : '' ?>>未知
                                            </option>
                                        </select>
                                    </div>
                                    <div class="am-form-group am-fl"  style="width:150px;">
                                        <div class="am-input-group am-input-group-sm tpl-form-border-form">
                                            <input type="text" class="am-form-field" name="UID"
                                                   placeholder="请输入用户ID"
                                                   value="<?= $request->get('UID') ?>">
                                        </div>
                                    </div>
                                    <div class="am-form-group am-fl">
                                        <div class="am-input-group am-input-group-sm tpl-form-border-form">
                                            <input type="text" class="am-form-field" name="sxkeyword"
                                                   placeholder="用户姓名/手机/备注"
                                                   value="<?= $request->get('sxkeyword') ?>">
                                        </div>
                                    </div>
                                    <div class="am-form-group am-fl"  style="width:100px;">
                                        <div class="am-input-group am-input-group-sm tpl-form-border-form">
                                            <input type="text" class="am-form-field" name="minmoney"
                                                   placeholder="输入最少余额"
                                                   value="<?= $request->get('minmoney') ?>">
                                        </div>
                                    </div>
                                    <div class="am-form-group am-fl" style="width:150px;">
                                        <div class="am-input-group am-input-group-sm tpl-form-border-form">
                                            <input type="text" class="am-form-field" name="nickName"
                                                   placeholder="输入微信昵称"
                                                   value="<?= $request->get('nickName') ?>">
                                            <div class="am-input-group-btn">
                                                <button class="am-btn am-btn-default am-icon-search"
                                                        type="submit"></button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>

                    <div class="am-scrollable-horizontal am-u-sm-12">
                        <div class="member-box">
                            <ul>

                                <?php

                                //$list[1]=$list[2]=$list[3]=$list[4]=$list[5]=$list[6]=$list[7]=$list[8]=$list[0];
                                if (!$list->isEmpty()): foreach ($list as $item):

                                ?>

                                <li>
                                    <dl class="person-info" {{if $item['gender']=='女'}}style="background: pink;"{{elseif $item['gender']=='未知'}}style="background:#5eb95e;"{{/if}}>



                                    <dt>
                                        <?php if ($item['avatarUrl']!=''): ?>
                                            <img src="<?= $item['avatarUrl'] ?>" width="72" height="72" alt="">
                                        <?php else: ?>
                                            <img src="/assets/store/img/dealer/avatar.png" width="72" height="72" alt="">
                                        <?php endif; ?>
                                        <label style="margin-top:10px;">{{if empty($item['grade'])}} 普通用户 {{else}} {{$item['grade']['name']}} {{/if}}</label>
<!--                                        <p>NO.{{$item['user_id']}}</p>-->
                                    </dt>
                                    <dd>
                            <span>
<!--                                <span>{{$item['true_name']}}</span>-->
							{{if $item['gender']=='男'}}
							<i class="am-icon-mars blue"></i>
								{{elseif $item['gender']=='女'}}
								<i class="am-icon-venus pink"></i>
								{{/if}}
                            <span style="font-weight:bold;">{{$item['nickName']}}</span>
                                <span>学号：{{$item['user_id']}}</span>
                                <span>生日：{{$item['user_birthstr']}}</span>
                            <span class="person-contact"><i class="am-icon-tablet"></i><em style="font-weight:bold;">{{$item['true_mobile']}}</em></span>
                                    </dd>
                                    </dl>
                                    <div class="person-address" {{if $item['gender']=='女'}}style="background: pink;"{{elseif $item['gender']=='未知'}}style="background:#5eb95e;"{{/if}}><i class="am-icon-map-marker"></i><span>
					{{$item['address']}} </span></div>
                        <div class="person-wallet">
                        <span>
                            <label>总余额</label>
                            <p style="color:#aa3333;">￥{{$item['balance']}}</p>
                        </span>
                            <span>
                            <label>积分</label>
                            <p style="color:#0000FF;">{{$item['points']}}</p>
                        </span>
                            <span>
                            <label>总消费</label>
                            <p style="color:#333;">￥{{$item['expend_money']}}</p>
                        </span>
                        </div>
                        <div class="person-introduce">
                            <div class="person-tag">
                                <a type="button" class="edittags" href="javascript:;" data-id="{{$item['user_id']}}" data-tagsids="{{$item['tags_ids']}}">打标签</a>
                                <?php if(empty($item['tags'])) $item['tags'] ='未设置标签';?>
                                {{~$tags = explode(',',$item['tags'])}}
                                {{foreach $tags as $tas}}
                                <span>{{$tas}}</span>
                                {{/foreach}}
                            </div>
                            <div class="person-notes">
                                备注：{{$item['user_remark']}}
                            </div>
                        </div>
                        <div class="person-source">
                            <dl>
                                <dt>来源：<span>{{$item['channelSource']==1?'小程序':'公众号'}}</span></dt><dd class="am-btn-group"><button class="am-btn am-btn-default">用户跟踪</button></dd>
                            </dl>
                            <dl>
                                <dt>打分：<span style="color:#F00;font-weight:bold;">{{$item['score']}}分</span></dt><dd><p>{{$item['create_time']}}</p></dd>
                                <!--{{$item['points']}}-->
                            </dl>
                            <div class="member-btns am-btn-toolbar">
                                <div class="am-btn-group"><?php if (checkPrivilege('user/recharge')): ?><button type="button" class="j-recharge am-btn am-btn-secondary {{if $item['gender']=='女'}}btn-pink{{elseif $item['gender']=='未知'}}btn-green{{/if}}" data-id="<?= $item['user_id'] ?>" data-balance="<?= $item['balance'] ?>" data-points="<?= $item['points'] ?>" title="用户充值">余额冲减</button> <?php endif; ?></div>
                                <div class="am-btn-group"><?php if (checkPrivilege('user/grade')): ?><button type="button" class="j-grade am-btn am-btn-secondary {{if $item['gender']=='女'}}btn-pink{{elseif $item['gender']=='未知'}}btn-green{{/if}}" data-id="<?= $item['user_id'] ?>" title="修改会员等级">修改信息</button> <?php endif; ?></div>
                                <div class="am-btn-group"><?php if (checkPrivilege('user/giftgoods')): ?><button type="button" class="j-giftgoods  am-btn am-btn-secondary {{if $item['gender']=='女'}}btn-pink{{elseif $item['gender']=='未知'}}btn-green{{/if}}" data-id="<?= $item['user_id'] ?>"   title="增加消费项目">增加消费项目</button> <?php endif; ?></div>
                                <div class="am-btn-group"><?php if (checkPrivilege('user/delete')): ?><!--<button type="button" class="j-delete am-btn am-btn-secondary" data-id="<?= $item['user_id'] ?>" title="删除用户">删除用户</button>--> <?php endif; ?>
                                    <div class="j-opSelect operation-select am-dropdown">
                                        <button type="button"
                                                class="am-dropdown-toggle am-btn am-btn-sm am-btn-secondary">
                                            <span>更多</span>
                                            <span class="am-icon-caret-down"></span>
                                        </button>
                                        <ul class="am-dropdown-content" data-id="<?= $item['user_id'] ?>">
                                            <?php if (checkPrivilege('order/all_list')): ?>
                                                <li>
                                                    <a class="am-dropdown-item" target="_blank"
                                                       href="<?= url('order/all_list', ['user_id' => $item['user_id']]) ?>">用户订单</a>
                                                </li>
                                            <?php endif; ?>
                                            <?php if (checkPrivilege('user.recharge/order')): ?>
                                                <li>
                                                    <a class="am-dropdown-item" target="_blank"
                                                       href="<?= url('user.recharge/order', ['user_id' => $item['user_id']]) ?>">充值记录</a>
                                                </li>
                                            <?php endif; ?>
                                            <?php if (checkPrivilege('user.balance/log')): ?>
                                                <li>
                                                    <a class="am-dropdown-item" target="_blank"
                                                       href="<?= url('user.balance/log', ['user_id' => $item['user_id']]) ?>">余额明细</a>
                                                </li>
                                            <?php endif; ?>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                            </li>
                            <?php endforeach; else: ?>
                                暂无记录
                            <?php endif; ?><ul></div>
                    </div>
                    <div class="am-u-lg-12 am-cf">
                        <div class="am-fr"><?= $list->render() ?> </div>
                        <div class="am-fr pagination-total am-margin-right">
                            <div class="am-vertical-align-middle">总记录：<?= $list->total() ?></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 模板：赠送项目模板 -->
<script id="tpl-giftgoods" type="text/template">
    <div class="am-padding-xs am-padding-top">
        <form class="am-form tpl-form-line-form" method="post" action="">
            <div class="am-form-group">
                <label class="am-u-sm-3 am-form-label"> 真实姓名 </label>
                <div class="am-u-sm-8 am-u-end">
                    <input type="text" min="0" class="tpl-form-input" readonly="readonly"
                           placeholder="请输入真实姓名" id="true_name" name="giftgoods[true_name]" >
                </div>
            </div>
            <div class="am-form-group">
                <label class="am-u-sm-3 am-form-label"> 手机号码 </label>
                <div class="am-u-sm-8 am-u-end">
                    <input type="text" min="0" class="tpl-form-input" readonly="readonly"
                           placeholder="请输入手机号码" id="true_mobile" name="giftgoods[true_mobile]" >
                </div>
            </div>

            <div class="am-form-group">
                <label class="am-u-sm-3 am-form-label"> 新增消费项目 </label>
                <div class="am-u-sm-8 am-u-end">
                    <button type="button" onClick="mmchooseGoods()" class="j-choose am-btn am-btn-secondary btn-green" data-id="11111" title="选择消费项目">选择消费项目</button>
                </div>
            </div>

            <div class="am-form-group">
                <label class="am-u-sm-3 am-form-label"> 商品ID/项目ID </label>
                <div class="am-u-sm-8 am-u-end">
                    <input id="xmidInput1" type="number" min="0" class="tpl-form-input" placeholder="请输入赠送商品ID/项目ID" id="goods_id" name="giftgoods[goods_id]" required>
                </div>
            </div>
            <div class="am-form-group">
                <label class="am-u-sm-3 am-form-label"> 确认ID </label>
                <div class="am-u-sm-8 am-u-end">
                    <input id="xmidInput2" type="number" min="0" class="tpl-form-input" placeholder="请输入确认商品ID/项目ID" id="goods_id" name="giftgoods[goods_id2]" required>
                </div>
            </div>
        </form>
    </div>
</script>

<!-- 模板：修改会员等级 -->
<script id="tpl-grade" type="text/template">
    <div class="am-padding-xs am-padding-top">
        <form class="am-form tpl-form-line-form" method="post" action="">
            <div class="am-tab-panel am-padding-0 am-active">
                <div class="am-form-group">
                    <label class="am-u-sm-3 am-form-label form-require">
                        会员等级
                    </label>
                    <div class="am-u-sm-8 am-u-end">
                        <select name="grade[grade_id]" id="grade_id"
                                data-am-selected="{btnSize: 'sm', placeholder: '请选择会员等级'}">
                            <option value="0">无等级</option>
                            <?php foreach ($gradeList as $item): ?>
                                <option value="<?= $item['grade_id'] ?>"
                                    <?= $grade == $item['grade_id'] ? 'selected' : '' ?>><?= $item['name'] ?>
                                </option>
                            <?php endforeach; ?>
                        </select>
                    </div>
                </div>

                <div class="am-form-group">
                    <label class="am-u-sm-3 am-form-label"> 真实姓名 </label>
                    <div class="am-u-sm-8 am-u-end">
                        <input type="text" min="0" class="tpl-form-input" placeholder="请输入真实姓名" id="true_name" name="grade[true_name]" >
                    </div>
                </div>

                <div class="am-form-group">
                    <label class="am-u-sm-3 am-form-label form-require">
                        会员性别
                    </label>
                    <div class="am-u-sm-8 am-u-end">
                        <div class="am-radio-inline"><label><input type="radio" name="grade[gender]" value="0">未知</label></div>
                        <div class="am-radio-inline"><label><input type="radio" name="grade[gender]" value="1">男</label></div>
                        <div class="am-radio-inline"><label><input type="radio" name="grade[gender]" value="2">女</label></div>


                    </div>
                </div>
                <div class="am-form-group">
                    <label class="am-u-sm-3 am-form-label"> 手机号码 </label>
                    <div class="am-u-sm-8 am-u-end">
                        <input type="text" min="0" class="tpl-form-input" placeholder="请输入手机号码" id="true_mobile" name="grade[true_mobile]" >
                    </div>
                </div>

                <div class="am-form-group">
                    <label class="am-u-sm-3 am-form-label"> 备注用户 </label>
                    <div class="am-u-sm-8 am-u-end">
                        <input type="text" min="0" class="tpl-form-input" placeholder="请输入用户备注" id="user_remark" name="grade[user_remark]" >
                    </div>
                </div>

                <div class="am-form-group">
                    <label class="am-u-sm-3 am-form-label"> 用户地址 </label>
                    <div class="am-u-sm-8 am-u-end">
                        <input type="text" min="0" class="tpl-form-input" placeholder="请输入用户地址" id="address" name="grade[address]" >
                    </div>
                </div>

            </div>
        </form>
    </div>
</script>

<script id="tpl-edittags" type="text/template">
    <form class="am-form tpl-form-line-form" method="post" action="">
        <?php
        $tags_type = \think\Db::name('tags_type')->select()->toArray();
        ?>

        {{foreach $tags_type as $ttype}}
        <?php
        $typelist =  \think\Db::name('tags_list')->where('typeid',$ttype['id'])->select()->toArray();
        ?>
        <div class="am-form-group">
            <label class="am-u-sm-3 am-form-label">{{$ttype.name}}：</label>
            <div class="am-u-sm-8 am-u-end">
                {{foreach $typelist as $tlist}}
                <label class="am-checkbox-inline">
                    <input type="checkbox" name="tags_id[]" value="{{$tlist.id}}"> {{$tlist.name}}
                </label>
                {{/foreach}}
            </div>
            {{/foreach}}
    </form>
</script>
<!-- 模板：用户充值 -->
<script id="tpl-recharge" type="text/template">
    <div class="am-padding-xs am-padding-top-sm">
        <form class="am-form tpl-form-line-form" method="post" action="">
            <div class="j-tabs am-tabs">

                <ul class="am-tabs-nav am-nav am-nav-tabs">
                    <li class="am-active"><a href="#tab1">充值余额</a></li>
                    <li><a href="#tab2">充值积分</a></li>
                </ul>

                <div class="am-tabs-bd am-padding-xs">

                    <div class="am-tab-panel am-padding-0 am-active" id="tab1">
                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-form-label">
                                当前余额
                            </label>
                            <div class="am-u-sm-8 am-u-end">
                                <div class="am-form--static">{{ balance }}</div>
                            </div>
                        </div>
                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-form-label">
                                充值方式
                            </label>
                            <div class="am-u-sm-8 am-u-end">
                                <label class="am-radio-inline">
                                    <input type="radio" name="recharge[balance][mode]"
                                           value="inc" data-am-ucheck checked>
                                    增加
                                </label>
                                <label class="am-radio-inline">
                                    <input type="radio" name="recharge[balance][mode]" value="dec" data-am-ucheck>
                                    减少
                                </label>
                                <label class="am-radio-inline">
                                    <input type="radio" name="recharge[balance][mode]" value="final" data-am-ucheck>
                                    最终金额
                                </label>
                            </div>
                        </div>

                        <div class="am-form-group" style="border-top:1px solid #efefef; padding-bottom:10px;
						border-bottom:1px solid #efefef;">
                            <label class="am-u-sm-3 am-form-label">
                                付款方式
                            </label>
                            <div class="am-u-sm-8 am-u-end">
                                <label class="am-radio-inline">
                                    <input type="radio" name="recharge[balance][payType]"
                                           value="1" data-am-ucheck>
                                    现金
                                </label>
                                <label class="am-radio-inline">
                                    <input type="radio" name="recharge[balance][payType]" value="2" data-am-ucheck>
                                    微信
                                </label>
                                <label class="am-radio-inline">
                                    <input type="radio" name="recharge[balance][payType]" value="3" data-am-ucheck>
                                    支付宝
                                </label>
                                <label class="am-radio-inline">
                                    <input type="radio" name="recharge[balance][payType]" value="4" data-am-ucheck>
                                    银行卡
                                </label>
                                <label class="am-radio-inline">
                                    <input type="radio" name="recharge[balance][payType]" value="5" data-am-ucheck>
                                    信用卡
                                </label>
                            </div>
                        </div>

                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-form-label">
                                冲减金额
                            </label>
                            <div class="am-u-sm-8 am-u-end">
                                <input type="number" min="0" class="tpl-form-input"
                                       placeholder="请输入要变更的冲减金额" name="recharge[balance][money]" value="0" required>
                            </div>
                        </div>
                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-form-label">
                                活动赠送金额
                            </label>
                            <div class="am-u-sm-8 am-u-end">
                                <input type="number" min="0" class="tpl-form-input"
                                       placeholder="请输入活动赠送金额" name="recharge[balance][giftmoney]" value="0" required>
                            </div>
                        </div>
                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-form-label">
                                管理员备注
                            </label>
                            <div class="am-u-sm-8 am-u-end">
                                <textarea rows="2" name="recharge[balance][remark]" placeholder="请输入管理员备注"
                                          class="am-field-valid"></textarea>
                            </div>
                        </div>
                    </div>

                    <div class="am-tab-panel am-padding-0" id="tab2">
                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-form-label">
                                当前积分
                            </label>
                            <div class="am-u-sm-8 am-u-end">
                                <div class="am-form--static">{{ points }}</div>
                            </div>
                        </div>
                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-form-label">
                                充值方式
                            </label>
                            <div class="am-u-sm-8 am-u-end">
                                <label class="am-radio-inline">
                                    <input type="radio" name="recharge[points][mode]"
                                           value="inc" data-am-ucheck checked>
                                    增加
                                </label>
                                <label class="am-radio-inline">
                                    <input type="radio" name="recharge[points][mode]" value="dec" data-am-ucheck>
                                    减少
                                </label>
                                <label class="am-radio-inline">
                                    <input type="radio" name="recharge[points][mode]" value="final" data-am-ucheck>
                                    最终积分
                                </label>
                            </div>
                        </div>
                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-form-label">
                                变更数量
                            </label>
                            <div class="am-u-sm-8 am-u-end">
                                <input type="number" min="0" class="tpl-form-input"
                                       placeholder="请输入要变更的数量" name="recharge[points][value]" value="" required>
                            </div>
                        </div>
                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-form-label">
                                管理员备注
                            </label>
                            <div class="am-u-sm-8 am-u-end">
                                <textarea rows="2" name="recharge[points][remark]" placeholder="请输入管理员备注"
                                          class="am-field-valid"></textarea>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </form>
    </div>
</script>

<script src="assets/common/js/vue.min.js?v=<?= $version ?>"></script>
<script src="assets/common/plugins/laydate/laydate.js"></script>
<script src="assets/store/js/select.data.js?v=<?= $version ?>"></script>

<script>
    function mmchooseGoods(){
        var app = this;
        $.selectData({
            title: '选择项目（每次只能选择1个项目，多选只生效第一个！！！）',
            uri: 'goods/lists&status=10',
            duplicate: true,
            dataIndex: 'goods_id',
            done: function (data) {
                if(data.length>1){
                    // alert('每次只能选择1个项目，多选只生效第一个！！！');
                    // return false;
                }
                console.log('可以故意写错代码如console2，控制台报错，点击错误很方便找到Sources源文件',data)
                setXMinput(data[0]['goods_id']);
                // data.forEach(function (item) {
                //     app.goodsList.push(item);
                // });
            },
            getExistData: function (ddd) {
                console.log(222,ddd)
                // var goodsIds = [];
                // app.goodsList.forEach(function (item) {
                //     goodsIds.push(item.goods_id);
                // });
                // return goodsIds;
            }
        });
    }
    function setXMinput(goodid){
        // $("#xmidInput1").val(goodid);
        // $("#xmidInput2").val(goodid);
    }

    $(function () {

        /**
         * 账户充值
         */
        $('.j-recharge').on('click', function () {
            //mmchooseGoods();

            var $tabs, data = $(this).data();
            $.showModal({
                title: '用户充值'
                , area: '460px'
                , content: template('tpl-recharge', data)
                , uCheck: true
                , success: function ($content) {
                    $tabs = $content.find('.j-tabs');
                    $tabs.tabs({noSwipe: 1});
                }
                , yes: function ($content) {
                    $content.find('form').myAjaxSubmit({
                        url: '<?= url('user/recharge') ?>',
                        data: {
                            user_id: data.id,
                            source: $tabs.data('amui.tabs').activeIndex
                        }
                    });
                    return true;
                }
            });
        });

        /**
         * 修改会员等级
         * @type {jQuery|HTMLElement}
         */
        $('.j-grade').on('click', function () {
            var data = $(this).data();
            $.showModal({
                title: '修改会员等级'
                , area: '460px'
                , content: template('tpl-grade', data)
                , uCheck: true
                , success: function ($content) {
                    $content.find('form').ajaxSubmit({
                        type: 'post',
                        dataType: 'json',
                        url: '<?= url('user/userInfo') ?>',
                        data: {user_id: data.id},
                        success: function (result) {
                            var gender=0;
                            if(result.gender=='未知') gender=0;
                            if(result.gender=='男') gender=1;
                            if(result.gender=='女') gender=2;
                            $('#grade_id').val(result.grade_id);
                            $('#remark').val(result.remark);
                            $('#true_name').val(result.true_name);
                            $('#true_mobile').val(result.true_mobile);
                            $('#user_remark').val(result.user_remark);
                            $('input[name="grade[gender]"][value="'+gender+'"]').prop('checked', true);
                            $('#address').val(result.address);

                        }
                    });
                }
                , yes: function ($content) {
                    $content.find('form').myAjaxSubmit({
                        url: '<?= url('user/grade') ?>',
                        data: {user_id: data.id}
                    });
                    return true;
                }
            });
        });
        // 赠送商品/赠送项目
        $('.j-giftgoods').on('click', function () {
            var data = $(this).data();
            $.showModal({
                title: '增加消费项目'
                , area: '460px'
                , content: template('tpl-giftgoods', data)
                , uCheck: true
                , success: function ($content) {
                    $content.find('form').ajaxSubmit({
                        type: 'post',
                        dataType: 'json',
                        url: '<?= url('user/userInfo') ?>',
                        data: {user_id: data.id},
                        success: function (result) {
                            $('#true_name').val(result.true_name);
                            $('#true_mobile').val(result.true_mobile);
                        }
                    });
                }
                , yes: function ($content) {
                    $content.find('form').myAjaxSubmit({
                        url: '<?= url('user/giftgoods') ?>',
                        data: {user_id: data.id}
                    });
                    return true;
                }
            });
        });

        $('.j-choose').on('click', function () {
            alert('33333');
        });

        //edittags
        $('.edittags').on('click', function () {
            var data = $(this).data();

            $.showModal({
                title: '打标签'
                , area: '460px'
                , content: template('tpl-edittags', data)
                , uCheck: true
                , success: function ($content) {
                    data['tags_id'] = data['tagsids'].split(',');
                    data['tags_id'].forEach(function(value) {
                        // 使用jQuery选择器选择具有匹配值的复选框
                        $('input[name="tags_id[]"][value="' + value + '"]').prop('checked', true);
                    });
                }
                , yes: function ($content) {
                    $content.find('form').myAjaxSubmit({
                        url: '<?= url('user/settags') ?>',
                        data: {user_id: data.id}
                    });
                    return true;
                }
            });
        });
        /**
         * 注册操作事件
         * @type {jQuery|HTMLElement}
         */
        var $dropdown = $('.j-opSelect');
        $dropdown.dropdown();
        $dropdown.on('click', 'li a', function () {
            var $this = $(this);
            var id = $this.parent().parent().data('id');
            var type = $this.data('type');
            if (type === 'delete') {
                layer.confirm('删除后不可恢复，确定要删除吗？', function (index) {
                    $.post("index.php?s=/store/apps.dealer.user/delete", {dealer_id: id}, function (result) {
                        result.code === 1 ? $.show_success(result.msg, result.url)
                            : $.show_error(result.msg);
                    });
                    layer.close(index);
                });
            }
            $dropdown.dropdown('close');
        });

        // 删除元素
        var url = "<?= url('user/delete') ?>";
        $('.j-delete').delete('user_id', url, '删除后不可恢复，确定要删除吗？');

    });
</script>

